package com.season.seasonStudy.javase.j_020_typeconvert;

import java.text.DecimalFormat;
import java.text.ParseException;

public class NumberUtil {
	
	public static String getString(double num, String geshi) {
		DecimalFormat df = new DecimalFormat(geshi);
		return df.format(num);
	}

	public static String getString(long num, String geshi) {
		DecimalFormat df = new DecimalFormat(geshi);
		return df.format(num);
	}

	public static Number getNumber(String num, String geshi) {
		DecimalFormat df = new DecimalFormat(geshi);
		try {
			return df.parse(num);
		} catch (ParseException e) {
			e.printStackTrace();
		}
		return null;
	}

}
